class CreateCores < ActiveRecord::Migration
  def self.up
    create_table :cores do |t|
	  t.string :type
	  
	  #common attributes
	  t.string :name, :null => false	  	  
	  t.string :colors, :null => false	  
    t.string :image_ext, :limit => 5
    t.integer :readings, :default => 0
    t.integer :image_id, :limit => 20
	  t.integer :vote, :default => 0
	  t.string :alias, :null => false
	  t.boolean :is_blocked, :default => false
	  t.boolean :is_backup, :default => false
	  t.text :description
	  t.text :sites
	  t.integer  :readings, :default => 0
	  t.integer :forum_topic_id, :limit => 20
	  t.integer :user_id, :limit => 20
	  t.timestamps
	  
	  # attributes for type=User      
	  t.column :login,                     :string    
    t.column :crypted_password,          :string, :limit => 40
    t.column :salt,                      :string, :limit => 40
    t.column :remember_token,            :string, :limit => 40
    t.column :remember_token_expires_at, :datetime
    t.column :activation_code,           :string, :limit => 40
    t.column :activated_at,              :datetime
    t.column :state,                     :string, :null => :no, :default => 'passive'
    t.column :deleted_at,                :datetime
    t.string :email
    t.boolean :newsletter
    t.boolean :is_admin
    t.integer :location_id, :limit => 20
    t.string :back_img, :limit => 10
    t.string :banner, :limit => 20
    t.string :banner_url
    t.boolean :notify_public_messages
    t.boolean :notify_private_messages
    t.boolean :notify_bookmark_events
    t.integer :max_distance
    t.text :bookmark_ids
	  t.string :last_ip, :limit => 20
	  t.datetime :last_login
    t.string :banner_file_name
    t.string :banner_content_type
    t.integer :banner_file_size
    t.column :fb_user_id,  :integer
    t.column :email_hash,  :string
	
   	  # attributes for type=Place
	  t.string :phone	  
    t.string :address
	  t.boolean :is_generic
	  t.integer :location_id, :limit => 20
	  
	  # attributes for type=Human
	  #----
	  
	  # attributes for type=Review
	  t.integer :core_id, :limit => 20
    t.string :category, :limit => 50
	  t.string :author
	  
	  # attributes for type=Event
    t.text :human_names
    t.string :human_ids
	  t.string :prices, :limit => 50
	  t.string :hours
    t.string :eid, :limit => 40
	  t.date :date, :default => Date.today
	  t.date :date_end, :default => Date.today
	  t.string :days_of_week
    t.integer :place_id, :limit => 20
    t.string :what_alias
    t.text :what_names
    t.integer :festival_id, :limit => 20
    t.boolean :is_cancelled
    t.boolean :with_pass  
    t.boolean :free_entry
    t.boolean :with_drink      
   end
   add_index :cores, :login, :unique => true
  end

  def self.down
    drop_table :cores
  end
end
